package top.mczhengyi.xyblog.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.mczhengyi.xyblog.entity.Blog;
import top.mczhengyi.xyblog.mapper.BlogMapper;
import top.mczhengyi.xyblog.service.BlogService;

import java.util.List;

@Service
public class BlogServiceImpl implements BlogService {
    @Autowired
    private BlogMapper blogMapper;

    @Override
    public Blog getBlogById(Integer id) {
        return blogMapper.selectBlogWithId(id);
    }

    @Override
    public List<Blog> getAllBlog() {
        return blogMapper.selectAllBlog();
    }

    @Override
    public List<Blog> getVisibleBlog() {
        return blogMapper.selectVisibleBlog();
    }

    @Override
    public Integer updateBlog(Blog blog) {
        return blogMapper.updateById(blog);
    }

    @Override
    public Integer saveBlog(Blog blog) {
        return blogMapper.insert(blog);
    }

    @Override
    public Integer delete(Integer id) {
        return blogMapper.deleteById(id);
    }
}
